﻿//using GoogleMobileAds.Api;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RewardedVideoButton : MonoBehaviour
{
//    private const string ACTION_NAME = "rewarded_video";

//    private void Start()
//    {
//        Timer.Schedule(this, 0.1f, AddEvents);
//    }

//    private void AddEvents()
//    {
//#if UNITY_ANDROID || UNITY_IOS
//        if (AdmobController.instance.rewardBasedVideo != null)
//        {
//            AdmobController.instance.rewardBasedVideo.OnAdRewarded += HandleRewardBasedVideoRewarded;
//        }
//#endif
//    }

//    public void OnClick()
//    {
//        if (IsAvailableToShow())
//        {
//#if UNITY_EDITOR
//            HandleRewardBasedVideoRewarded(null, null);
//#else
//            AdmobController.instance.ShowRewardBasedVideo();
//#endif
//        }
//        else
//        {
//            Toast.instance.ShowMessage("Ad is not available at the moment");
//        }
        
//        Sound.instance.PlayButton();
//    }

//    public void HandleRewardBasedVideoRewarded(object sender, Reward args)
//    {
//        Timer.Schedule(this, 0.3f, () =>
//        {
//            var dialog = (RewardedVideoDialog)DialogController.instance.GetDialog(DialogType.RewardedVideo);
//            dialog.SetAmount(ConfigController.Config.rewardedVideoAmount);
//            DialogController.instance.ShowDialog(dialog);
//        });

//        CUtils.SetActionTime(ACTION_NAME);
//    }

//    public bool IsAvailableToShow()
//    {
//        return IsActionAvailable() && IsAdAvailable();
//    }

//    private bool IsActionAvailable()
//    {
//        return CUtils.IsActionAvailable(ACTION_NAME, ConfigController.Config.rewardedVideoPeriod);
//    }

//    private bool IsAdAvailable()
//    {
//        if (AdmobController.instance.rewardBasedVideo == null) return false;
//        bool isLoaded = AdmobController.instance.rewardBasedVideo.IsLoaded();
//        return isLoaded;
//    }

//    private void OnDestroy()
//    {
//#if UNITY_ANDROID || UNITY_IOS
//        if (AdmobController.instance.rewardBasedVideo != null)
//        {
//            AdmobController.instance.rewardBasedVideo.OnAdRewarded -= HandleRewardBasedVideoRewarded;
//        }
//#endif
//    }
}
